#!/usr/bin/env bash

# 硬盘容量 使用情况
print_disk_icon() {
    # df -h --output=target,used,size,pcent
    # df -h --output=target,used,size,pcent
    # disk_text="$(df -h / | awk ' /[0-9]/ {print $2 }')"
    disk_icon=""
    # text=" $disk_icon $disk_text"
    echo $disk_icon;
}

print_disk_total_size() {
    # df -h --output=target,used,size,pcent
    # df -h --output=target,used,size,pcent
    disk_text="$(df -h / | awk ' /[0-9]/ {print $2 }')"
    # disk_icon=""
    # text=" $disk_icon $disk_text"
    text="$disk_text"
    echo $text;
}

print_disk_free_size() {
    # df -h --output=target,used,size,pcent
    disk_text="$(df -h / | awk ' /[0-9]/ {print $4 }')"
    # disk_icon=""
    # text=" $disk_icon $disk_text"
    text="$disk_text"
    echo $text;
}

print_disk_used_total_size() {
    # df -h --output=target,used,size,pcent
    disk_text="$(df -h / | awk ' /[0-9]/ {print $3 "/" $2}')"
    # disk_icon=""
    # text=" $disk_icon $disk_text"
    text="$disk_text"
    echo $text;
}

print_disk_used_pcent() {
    # df -h --output=target,used,size,pcent
    # df -h /dev/sda1 | awk ' /[0-9]/ {print $3 "/" $2}'
    # df -h / | awk ' /[0-9]/ {print $3 "/" $2}'
    # disk_text="$(df -h / | awk ' /[0-9]/ {print $3 "/" $2}')"
    # disk_text="$(df -h / | awk ' /[0-9]/ {print $5 }')"
    disk_text="$(df -h / | awk ' /[0-9]/ {print $5 }' | sed 's/%//g')"
    #   禍 
    # disk_icon=""

    # text=" $disk_icon $disk_text"
    text="$disk_text"
    echo $text;
}

manager() {
    # cd $HOME
    # eww close-all
    eww --config ${HOME}/.dwm/scripts/config/eww close-all
    # pavucontrol &
    thunar &
}

if [[ $1 == "--total" ]]; then
    print_disk_total_size
elif [[ $1 == "--free" ]]; then
    print_disk_free_size
elif [[ $1 == "--usedtotalsize" ]]; then
    print_disk_used_total_size
elif [[ $1 == "--pcent" ]]; then
    print_disk_used_pcent
elif [[ $1 == "--icon" ]]; then
    print_disk_icon
elif [[ $1 == "--manager" ]]; then
    manager
fi
